package com.start.workflow.core.configs;

import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.DbSqlSessionFactory;
import org.activiti.engine.impl.persistence.cache.EntityCache;
import org.apache.commons.lang3.StringUtils;

public class StartActDBSqlSession extends DbSqlSession {
    private final StartActOtherDataBase dataBaseExt;

    public StartActDBSqlSession(StartActOtherDataBase dataBaseExt, DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache) {
        super(dbSqlSessionFactory, entityCache);
        this.dataBaseExt = dataBaseExt;
    }

    public String getResourceForDbOperation(String directory,
                                            String operation,
                                            String component) {
        String resourceForDbOperation = dataBaseExt.getResourceForDbOperation(operation, component);
        if (StringUtils.isNotBlank(resourceForDbOperation)) {
            return resourceForDbOperation;
        }
        return super.getResourceForDbOperation(directory, operation, component);
    }
}
